import java.util.concurrent.Callable;

public class Animal {
    public String name;
    public void play(){
        System.out.println("动物正在玩");
    }
    public Animal(String name) {
        this.name = name;
    }
    public static void playAnimal(Animal animal){
        animal.play();
    }
    public static void main(String[] args) {
        /*Dog dog = new Dog("小狗");
        playAnimal(dog);
        Cat cat = new Cat("小猫");
        playAnimal(cat);*/
        Animal animal = new Dog("小狗");
        //如果animal引用的对象是Cat对象的实例
        if(animal instanceof Cat){
            Cat cat = (Cat)animal;
            cat.speak();
        } else {
            System.out.println("here");
        }
    }
}

class Dog extends Animal{
    public Dog(String name) {
        super(name);
    }

    @Override
    public void play() {
        System.out.println(name+"正在玩");
    }
}
class Cat extends Animal{
    public Cat(String name) {
        super(name);
    }
    public void speak(){
        System.out.println("喵喵");
    }
    @Override
    public void play() {
        System.out.println(name+"正在玩");
    }
}

/*    public void fun1(){
        System.out.println("父类");
    }*/
/*    @Override
    public String toString() {
        return "Animal{}";
    }*/
/*Dog dog = new Dog();
System.out.println(dog);*//*
        Animal animal = new Dog();
        animal.fun1();*/
/*    public void fun1(){
        System.out.println("子类");
    }*/
/*
public class Animal {
    public int a = 1;
    public void func1(){
        System.out.println("Animal");
    }
    public static void main(String[] args) {
        Animal animal = new Dog();
        System.out.println(animal);
*/
/*        Animal animal = new Dog();
        animal.func1();*//*

*/
/*        System.out.println(animal.a);
        System.out.println(animal);*//*

    }
}
class Dog extends Animal{
    public void func1(){
        System.out.println("Dog");
    }
    public int b = 2;
}
*/
/*
public class Animal {
    protected Animal stay(){
        System.out.println("Animal");
        return null;
    }

*//*

*/
/*    @Override
    public String toString() {
        return "Animal{}";
    }*//*
*/
/*


    public static void main(String[] args) {
        Dog dog = new Dog();
        System.out.println(dog);
//        dog.stay();
    }
}
class Dog extends Animal{
*//*

*/
/*    public Dog stay(){
        return null;
    }*//*
*/
/*


    @Override
    public String toString() {
        return "Dog{}";
    }
    *//*

*/
/*    @Override
    public Animal stay() {
        System.out.println("Dog");
        return super.stay();
    }*//*
*/
/*

}
*/
